//
//  Bucket.swift
//  ChargeManager
//
//  Created by solarke_apple_mini_1 on 16/9/2.
//  Copyright © 2016年 石家庄科林电气股份有限公司. All rights reserved.
//


import UIKit

class Bucket: NSObject {
    fileprivate var data = [String: AnyObject]()
    fileprivate static let instance = Bucket()
    
    // MARK: - Singleton
    fileprivate override init() {
        super.init()
    }
    
    static func defaultBucket() -> Bucket {
        return instance
    }
    
    // MARK: - Function
    func bucketIn(_ key: String, value: AnyObject) {
        data[key] = value
    }
    
    func bucketOut(_ key: String) -> AnyObject? {
        let value = data[key]
        data[key] = nil
        return value
    }
    
    override func value(forKey key: String) -> Any? {
        return data[key]
    }
}

